# -*- coding:UTF-8 -*-
"""
@Project : SeleniumAutoTest
@File    : example-tanchuang.py
@IDE     : PyCharm
@Author  : WorldWind(1772830365@qq.com)
@Address : China - HeiLongjiang - Herbin
@Date    : 2025/8/3 上午10:41
"""
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service

service = Service("D:\chromedriver-win64\chromedriver.exe")  # 配置chromedriver文件
dr = webdriver.Chrome(service=service)
dr.maximize_window()
dr.get("file:///D:/xwechat_files/wxid_cm0sp0osvt7l22_8a98/msg/file/2025-08/zonghe.html")
sleep(2)
# 第四个案例
# dr.find_element(By.XPATH, '/html/body/div[1]/div/button[4]').click() # 打开弹窗
# sleep(2)
# dr.find_element(By.XPATH,'//*[@id="myModal"]/div/div[3]/button').click() # 关闭弹窗
# sleep(2)

# 第三个案例
# dr.find_element(By.XPATH, '/html/body/div[1]/div/button[3]').click()
# sleep(2)
# print(dr.switch_to.alert.text)  # 获取弹框的文本信息
# dr.switch_to.alert.send_keys('张三')  # 点击弹框ok按钮
# sleep(2)
# dr.switch_to.alert.accept()  # 点击弹框ok按钮
# sleep(2)
# dr.switch_to.alert.accept() # 点击第二个弹框OK按钮





sleep(5)
dr.quit()
